package it.polimi.traveldream.ejb.dtocreator;

import it.polimi.traveldream.ejb.entities.Participation;
import it.polimi.traveldream.ejbclient.dtos.ParticipationDTO;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class ParticipationDTOCreator {
	public static ParticipationDTO createParticipation(Participation entity) {
		return entity != null ? new ParticipationDTO(entity.getReservations(), entity.getTimestamp(),
				TravelPackageDTOCreator.createTravelPackage(entity.getTravelpackage()),
				UserDTOCreator.createUser(entity.getUser()))
		: null;
	}
	
	public static List<ParticipationDTO> createParticipationList(Collection<Participation> entities) {
		if(entities != null && !entities.isEmpty()) {
			List<ParticipationDTO> participations = new ArrayList<ParticipationDTO>();
			for(Participation entity : entities) {
				participations.add(createParticipation(entity));
			}
			return participations;
		}
		return null;
	}
	
}
